import serverHelper

import asyncio

from aiohttp import web

ip='127.0.0.1'
port=10010

async def index(request):
    await asyncio.sleep(0.2)
    print(request.headers)
    await serverHelper.extract_jpg(request)
    ftj=serverHelper.FrameToJson()
    ftj.append_frame(50,60,100,120,"tttt")
    resp=ftj.get_json()
    
    print(resp)
    return web.Response(body=resp)

async def init(loop):
    global ip,port
    app = web.Application(loop=loop)
    app.router.add_route('POST', '/', index)
    srv = await loop.create_server(app.make_handler(), ip, port)
    print('Server started at {}:{}...'.format(ip,port))
    return srv

loop = asyncio.get_event_loop()
loop.run_until_complete(init(loop))
loop.run_forever()
